package com.lp.guidepage.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.coorchice.library.SuperTextView;
import com.lp.guidepage.R;

import fkg.client.side.ui.StartActivity;

/**
 * admin
 * 2019/1/11
 * content :
 */
public class LaunchFragment extends BaseFragment {

    private int flag;
    private SuperTextView launchJump;
    private RelativeLayout launchBg;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.launch_fragment, container, false);
        launchJump = view.findViewById(R.id.launch_jump);
        launchBg = view.findViewById(R.id.launch_bg);
        initData();
        return view;
    }

    public LaunchFragment setFlag(int flag) {
        this.flag = flag;
        return this;
    }

    @Override
    protected void lazyLoad() {

    }

    private void initData() {
        switch (flag) {
            case 0:
                launchBg.setBackgroundResource(R.mipmap.bootpage_one);
                break;
            case 1:
                launchBg.setBackgroundResource(R.mipmap.bootpage_two);
                break;
            case 2:
                launchJump.setVisibility(View.VISIBLE);
                launchBg.setBackgroundResource(R.mipmap.bootpage_three);
                break;
        }
        launchJump.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), StartActivity.class));
                getActivity().finish();
            }
        });
    }

}
